<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>lyf音乐</title>
  <style>
    body{
      margin: 0;
      padding:0;
    }
    body>.title{
      position: fixed;
      top: 0;
      left: 0;
      width: 100vw;
      height: 50px;
      background: rgb(77, 85, 237);
      text-align: center;
      line-height: 50px;
      font-size: 30px;
      color: aliceblue;
      z-index: 9;
    }
    .list{
      padding: 50px 10px 10px;
      box-sizing: border-box;
    }
    .list .item{
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-top: 10px;
    }
    .img-wrap{
      position: relative;
      width: 20vw;
      height: 20vw;
      background-color: rgb(227, 242, 237);
      overflow: hidden;
      border-radius: 10px;
    }
    .img-wrap img{
      position: absolute;
      top: 50%;
      width: 100%;
      transform: translateY(-50%);
    }
    .item .title{
      width: 63vw;
      height: 50px;
      font-size: 20px;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .item .play{
      font-size: 30px;
    }
  </style>
  <script src="./js/axios.js"></script>
</head>
<body>
  <div class="title">lyf音乐</div>
  <div class="list" id="list">
    <!-- <div class="item">
      <div class="img-wrap">
        <img src="" alt="" srcset="">
      </div>
      <div class="title">我事个名字和萨哈哈哈哈哈哈哈哈哈</div>
      <div class="play">▶️</div>
    </div> -->
  </div>
</body>
<script>
  window.onload=()=>{
    let list=document.getElementById("list")
    axios.get("/musicApi/top/artists?offset=0&limit=30").then(res=>{
      if(res.status==200){
        let str=""
        res.data.artists.forEach(item=>{
          let url=item.picUrl+'?param=200y200'
          str+=`
          <div class="item" data-id="${item.id}" data-url="${item.picUrl+'?param=200y200'}">
            <div class="img-wrap">
              <img src="${url}" >
            </div>
            <div class="title">${item.name}</div>
            <div class="play">...</div>
          </div>
          `
        })
        list.innerHTML=str
        setTimeout(() => {
          let items=list.querySelectorAll(".item")
          items.forEach((i,index)=>{
            i.onclick=()=>{
              let id=res.data.artists[index].id
              let url=res.data.artists[index].picUrl
              window.location.href=`/music/playerDetail.html?id=${id}&src=${url}`
            }
          })
        }, 500);
      }
		})
  }
</script>
</html>